<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
						<li>
								题号：<input type="text" name="id" style="width:100px;"/>
							</li>
							<li>
								<input id="pid" name="pid" type="hidden"/>
								<input id="treeId" name="kbid" pid="" type="hidden" th:value="${qdb.id}"/>
								<input class="form-control" type="text" id="treeName" onclick="selectTree()" readonly="true" th:value="${qdb.name}"/>
							</li>

							<li>
                            <select id="qtid"  name="qtid" class="form-control noselect2 selectpicker">
                            	<option value=""> -- 请选择题型 -- </option>
                            	<option th:each="qtype : ${qtypes}" th:value="${qtype.id}" th:text="${qtype.name}">

                            </select>
							</li>
							<li>
								题干：<input type="text" name="name"  style="width:100px;"/>
							</li>

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.addFull()" shiro:hasPermission="exam:question:add">
					<i class="fa fa-plus"></i> 添加
				</a>
				<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="exam:question:edit">
					<i class="fa fa-edit"></i> 修改
				</a>
				<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="exam:question:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
				<a class="btn btn-info" onclick="$.table.importExcel()" shiro:hasPermission="exam:question:import">
		            <i class="fa fa-upload"></i> 导入
		        </a>
	            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="exam:question:export">
		            <i class="fa fa-download"></i> 导出
		        </a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var prefix = ctx + "exam/question";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                detailUrl: prefix + "/detail/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
				importUrl: prefix + "/importData",
		        importTemplateUrl: prefix + "/importTemplate",
                modalName: "题目",
				search: false,
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'id', 
					title : '题号'
				},
				{
					field : 'qdbid', 
					title : '题库代码',
					sortable: true
				},
				{
					field : 'kbid', 
					title : '知识块代码',
					sortable: true
				},
				{
					field : 'qtid', 
					title : '题型代码',
					sortable: true
				},
				{
					field : 'qteasy', 
					title : '难易度1非常容易-5非常难',
					sortable: true
				},
				/* {
					field : 'name', 
					title : '题干',
					sortable: true
				}, */
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs " href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i> 编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs " href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i> 删除</a> ');
                        actions.push('<a class="btn btn-warning btn-xs " href="#" onclick="$.operate.detail(\'' + row.id + '\')"><i class="fa fa-search"></i> 详细</a>');
                        return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
        function selectTree() {
            var treeId = $("#treeId").val();
        	var id = $.common.isEmpty(treeId) ? "1" : $("#treeId").val();
            var options = {
                title: '选择上级',
                width: "380",
                url: ctx + "exam/qdb/selectTree/" + id,
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }


	function doSubmit(index, layero) {
		//var tree = layero.find("iframe")[0].contentWindow.$._tree;
		var body = layer.getChildFrame('body', index);
		$("#treeId").val(body.find('#treeId').val());
		$("#pid").val(body.find('#treeId').attr("pid"));
		$("#treeName").val(body.find('#treeName').val());
		layer.close(index);
	}
</script>
<form id="importTpl" enctype="multipart/form-data" class="mt20 mb10" style="display: none;">
	<div class="col-xs-offset-1">
		<input type="file" id="file" name="file"/>
		<div class="mt10 pt5">
			<input type="hidden" id="updateSupport" name="updateSupport" > 
			 &nbsp;&nbsp;	<a onclick="$.table.importTemplate()" class="btn btn-default btn-xs" shiro:hasPermission="exam:question:importTemplate">
			 <i class="fa fa-file-excel-o"></i> 下载模板
			 </a>
		</div>
		<font color="red" class="pull-left mt10">
			提示：仅允许导入“xls”或“xlsx”格式文件！
		</font>
	</div>
</form>
</body>
</html>